<include file="Public/head"/>

<body class="no-skin">
<include file="Public/header"/>
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>

    <include file="Public/sidebar"/>
    <div class="main-content">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            <include file="Public/breadcrumbs"/>
            <!-- /section:basics/content.breadcrumbs -->
            <div class="page-content">
                <include file="Public/set"/>

                <!-- /section:settings.box -->
                <div class="row">
                     <div class="cf">
                            <form class="form-inline" action="" method="get">
                                <a class="btn btn-info" href="{:U('add')}" value="">新增公告</a>

                                <label class="inline">公告标题</label>
                                <input type="text" name="title" id="title" value="{:I('title')}" class="form-control">
                                <button type="button" onclick="sou()" class="btn btn-purple btn-sm">
                                    <span class="ace-icon fa fa-search icon-on-right bigger-110"></span>
                                    搜索
                                </button>
                            </form>
                        </div>
                    <div class="space-4"></div>
                      <table class="table table-striped table-bordered">
                            <thead>
                            <tr>
                                <th class='center'>序号</th>
                                <th class='center'>公告标题</th>
                                <th class='center'>摘要</th>
                                <th class='center'>缩略图</th>
                                <th class='center'>发布公告时间</th>
                                <th class='center'>操作</th>
                            </tr>
                            </thead>
                            <tbody>

                            <?php if($data){
                                foreach($data as $key=>$val){ ?>
                                 <tr>

                                     <td class='center'><?php echo $key+1 ;?></td>
                                     <td class='center  col-xs-3'><?php echo $val['title']?></td>
                                     <td class='center col-xs-3'><?php echo $val['intro']?></td>
                                     <td class='center col-xs-1'><img style="width:95%; height:80px;" src="<?php echo $val['picture']?>" /></td>
                                     <td class='center'>{$val['add_time']|date="Y-m-d ",###}</td>
                                    <td class='center '><a href="<?php echo U('edit',array('id'=>$val['id']));?>"><i
                                            class="ace-icon fa fa-pencil bigger-100"></i>编辑</a>&nbsp;&nbsp;
                                        <a href="javascript:;" val="<?php echo U('del',array('id'=>$val['id']));?>" class="del"><i
                                                class="ace-icon fa fa-trash-o bigger-100 red"></i>删除</a>
                                    </td>

                                </tr>
                            </foreach>
                            <?php }}else{echo "<tr align='center'><td colspan='9'>暂未添加公告信息，请添加公告！</td></tr>";}?>
                            </tbody>
                        </table>
                    {$page}
                    <!-- PAGE CONTENT ENDS -->
                </div><!-- /.col -->
            </div><!-- /.row -->
        </div><!-- /.page-content -->
    </div>
</div><!-- /.main-content -->
<include file="Public/footer"/>

</div><!-- /.main-container -->

<include file="Public/footerjs"/>
<!-- inline scripts related to this page -->
<script type="text/javascript">
    $(".del").click(function () {
            var url = $(this).attr('val');
        //alert(url);
        //return false;
            bootbox.confirm({
                title: "系统提示",
                message: "确定要删除该公告吗?",
                callback: function (result) {
                    if (result) {
                        window.location.href = url;
                    }
                },
                buttons: {
                    "cancel": {"label": "取消"},
                    "confirm": {
                        "label": "确定",
                        "className": "btn-danger"
                    }
                }
            });
        });
    function setStatus(a){
        var status_id = a.value;
        $.ajax({
            type:'post',
            url:"{:U('setStatus')}",
            async:false,
            data:{'status_id':status_id},
            dateType:'json',
            success:function(data){
                var data = eval('('+data+')');//转换为对象
                if(data.res == 1){
                   bootbox.dialog({
                            title: '友情提示：',
                            message: '修改'+data.msg,
                            buttons: {
                                "success": {
                                    "label": "确定",
                                    "className": "btn-danger"
                                }
                            }
                        });
                        return false;
                }else{
                    bootbox.dialog({
                            title: '友情提示：',
                            message: '修改'+data.msg,
                            buttons: {
                                "success": {
                                    "label": "确定",
                                    "className": "btn-danger"
                                }
                            }
                        });
                        return false;
                }
            }
            
        });

    }
    function sou(){
        var title = $('#title').val();
        var param = '';
        if(title){
            param += '/title/'+title;
        }

        location.href="__APP__/Admin/Notice/index"+param+".html";
    }
</script>
</body>
</html>
